<template>
    
    <el-button type="default" @click="closeWindow" circle size="large">
        <SvgIcon name="close" color="#999" size="24" />
    </el-button>

    <el-dialog v-model="dialogVisible" title="提示" width="500">
        <span>确定退出程序？</span>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="dialogVisible = false" size="large">取消</el-button>
                <el-button type="primary" size="large" @click="confirmCloseWindow">
                    确定
                </el-button>
            </div>
            <el-divider />
            <div>
                <el-button type="danger" style="width: 100%;" size="large" @click="shutdownComputer">关机</el-button>
            </div>
        </template>
    </el-dialog>
</template>


<script setup lang='ts'>

import { ref } from 'vue'
const dialogVisible = ref(false) //关闭弹窗
//关闭程序
function confirmCloseWindow() {
    dialogVisible.value = false
    window.electron.ipcRenderer.send('close-window')
}
//退出
const closeWindow = () => {
    dialogVisible.value = true
}

//关闭计算机
function shutdownComputer() {
    window.electron.ipcRenderer.send('shutdown-computer')
}
</script>